package com.wxy.controller;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.wxy.dao.UserMapper;
import com.wxy.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author 47868
 */
@Controller
@RequestMapping("test")
public class TestController {
    private final UserMapper userMapper;
    public TestController(UserMapper userMapper) {
        this.userMapper = userMapper;
    }
    @RequestMapping("test1")
    @ResponseBody
    @Transactional
    public String test1() {
        try {
            User user = new User(4,"wang","1111111");
            userMapper.insert(user);
            int i=1/0;
            System.out.println(i);
            userMapper.update(new UpdateWrapper<User>().eq("id",1).set("password","1111"));
            return "success";
        }
        catch (Exception e) {
            throw new RuntimeException("异常...");
        }
    }
}
